package cn.heroes.weixin.commons;

import net.sf.json.JSONObject;

/**
 * JSON工具类
 * @author cq
 *
 */
public class JSONUtils {

	//private static final Logger logger = LoggerFactory.getLogger(JSONUtils.class);

	/**
	 * 将JSON字符串(非Array)转化成Bean
	 * @param json JSON字符串
	 * @param clazz Bean类
	 * @return Java Bean对象
	 * @throws Exception 转化出错
	 */
	@SuppressWarnings("unchecked")
	public static <T> T toBean(String json, Class<T> clazz) throws RuntimeException {
		return (T)JSONObject.toBean(JSONObject.fromObject(json), clazz);
	}
}
